package cn.tedu.controller;

import cn.tedu.pojo.Comment;
import cn.tedu.service.CommentService;
import cn.tedu.vo.PageResult;
import cn.tedu.vo.SysResult;
import com.baomidou.mybatisplus.annotation.IdType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author:努力学java的小雨
 * @创建时间:2021/9/15 9:35
 */
@RestController
@RequestMapping("/comment")
@CrossOrigin
public class CommentController {
    @Autowired
    private CommentService commentService;
    @GetMapping("/findAll")
    public List<Comment>list(){
        return commentService.findAll();
    }
    @GetMapping("/find")
    public SysResult getComment( PageResult pageResult){
        pageResult=commentService.getComment(pageResult);
        return SysResult.success(pageResult);
    }
    @PostMapping("/addComment")
    public SysResult postComment(@RequestBody Comment comment){
        commentService.postComment(comment);
        return SysResult.success();
    }
    @DeleteMapping("/{id}")
    public SysResult deleteComment(@PathVariable Integer id){
        commentService.deleteComment(id);
        System.out.println("删除");
        return SysResult.success();
    }
}
